﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ZhCun.Win
{
    public partial class UcBaseDockControl : UserControl
    {
        public UcBaseDockControl()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 父级窗体
        /// </summary>
        public FrmBase HostForm { get { return Parent as FrmBase; } }
        /// <summary>
        /// 用于显示标题文本
        /// </summary>
        public virtual string Title { get; } = "默认窗体";
        /// <summary>
        /// 显示文本消息
        /// </summary>
        public void ShowMessage(string msg)
        {
            if (HostForm != null)
            {
                HostForm.ShowMessage(msg);
            }
            else
            {
                MessageBox.Show(msg);
            }
        }
        /// <summary>
        /// 开始耗时工作
        /// </summary>
        public void StartWorking(Action WorkHandle, Action WorkAfterHandle = null)
        {
            if (HostForm != null)
            {
                HostForm.StartWorking(WorkHandle, WorkAfterHandle);
            }
            else
            {
                WorkHandle();
                WorkAfterHandle();
            }
        }
    }
}
